// MyTime.h: 
//
//////////////////////////////////////////////////////////////////////
#pragma once

//#define WINVER 0x0601
#define _WIN32_WINNT 0x0601
#define VC_EXTRALEAN
#define _AFX_ALL_WARNINGS
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS

// time lengths in 100 nanosec
#define LEN_MS		(__int64)10000
#define LEN_SEC		(__int64)10000000
#define MAX_LONG	999999999

#include <afxwin.h>         // MFC core and standard components

// api for faster time processing
class CMyTime : public SYSTEMTIME
{
public:
	CMyTime();
	CMyTime(CMyTime &mt);
	CMyTime(DATE &date);

	int    GetDiffSec(CMyTime &mt);
	BOOL	IsCorrect();
	BOOL	IsNull();
	void    SetTime(WORD Year, WORD Month, WORD Day, WORD Hour, WORD Minute, WORD Second, WORD Millisecond);
	void	ClearTime();
	void	SetCurrentTime();
	CString GetLongTime();
	CString GetShortTime();
	CString GetShortTimeEx();
	
	CMyTime& operator=(const DATE &mt);
	CMyTime& operator=(const time_t &mt);
	CMyTime& operator=(const CTime &mt);
	CMyTime& operator=(const ULONGLONG &mt);
	int operator-(const CMyTime &mt);
	void operator-=(const int shift_ms);
	void operator+=(const int shift_ms);
	BOOL operator==(const CMyTime &mt);
	BOOL operator<=(const CMyTime &mt);
	BOOL operator>=(const CMyTime &mt);
	BOOL operator!=(const CMyTime &mt);
	BOOL operator!=(const DATE &mt);
	BOOL operator<(const CMyTime &mt);
	BOOL operator>(const CMyTime &mt);
};

class CMySTime
{
	int m_time;
	
public:
	CMySTime();
	CMySTime(CMySTime &mt);
	CMySTime(DATE &date);

	static int time_shift;
	
	int		GetHour();
	int		GetMin();
	int		GetSec();
	int		GetMs();

	int		GetHourCount();
	int		GetMinCount();
	int		GetSecCount();
	int		GetMsCount();

	void	SetHour(int Hour);
	void	SetMin(int Min);
	void	SetSec(int Sec);
	void	SetMs(int Ms);

	int     GetDiffSec(CMySTime &mt);
	BOOL	IsCorrect();
	BOOL	IsNull();
	void    SetTime(WORD Hour, WORD Minute, WORD Second, WORD Millisecond);
	void	ClearTime();
	void	SetCurrentTime();
	CString GetShortTime();
	CString GetShortTimeEx();
	void	Shift();
	static void	InitTimeShift();

	void	  SetFromTimeT32(const long &mt);		// named function just to be different from int &mt
	void	  SetFromTimeT64(const __int64 &mt);	// named function just to be different from ULONGLONG &mt
	CMySTime& operator=(const DATE &mt);
	CMySTime& operator=(const CTime &mt);
	CMySTime& operator=(const ULONGLONG &mt);
	CMySTime& operator=(const CMyTime &mt);
	CMySTime& operator=(const int &mt);
	int operator-(const CMySTime &mt);
	void operator-=(const int shift_ms);
	void operator+=(const int shift_ms);
	BOOL operator==(const CMySTime &mt);
	BOOL operator<=(const CMySTime &mt);
	BOOL operator>=(const CMySTime &mt);
	BOOL operator!=(const CMySTime &mt);
	BOOL operator!=(const DATE &mt);
	BOOL operator<(const CMySTime &mt);
	BOOL operator>(const CMySTime &mt);
};